package woa.test;

/**
 * @author wangpeng
 * @version 1.0
 * @date 2024/10/28 21:38
 */
public class MqTest1 {

    private static final Object producerLock = new Object();
    private static final Object consumerLock = new Object();

    public static void main(String[] args) {
        Thread producer = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("producer start");
                System.out.println("product........");
                synchronized (producerLock) {
                    try {
                        wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("producer end");
                synchronized (consumerLock) {
                    notify();
                }
            }
        });

        Thread consumer = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("consumer start");

                System.out.println("consumer end");
            }
        });

        producer.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        consumer.start();
    }
}
